package com.junjie.checkin.controller;

import com.junjie.checkin.mapper.StudentGiftMapper;
import com.junjie.checkin.request.gift.GiftOrderPageRequest;
import com.junjie.checkin.response.PageResult;
import com.junjie.checkin.response.Result;
import com.junjie.checkin.response.ResultStatus;
import com.junjie.checkin.response.front.GiftOrderResponse;
import com.junjie.checkin.service.StudentGiftService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 洪浚杰
 * @description 礼品订单
 * @date 2025/6/18 20:06
 */
@RestController
@RequestMapping("/orders")
public class GiftOrderController {
    @Autowired
    private StudentGiftService studentGiftService;

    /**
     * 用户查询礼品订单
     * @return
     */
    @GetMapping("")
    public Result<PageResult<GiftOrderResponse>> getGiftOrder(HttpServletRequest request , GiftOrderPageRequest pageRequest) {
        pageRequest.initDefault();
        String token = request.getHeader("Authorization");
        PageResult<GiftOrderResponse> giftOrderList = studentGiftService.getGiftOrderList(token, pageRequest);
        return Result.getResult(ResultStatus.OK, giftOrderList);
    }
}
